<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>组合继承</title>
</head>
<body>
<script>
    function Person(name){
        this.name=name;
    }
    Person.prototype.sayName=function(){
        alert(this.name);
    }
    function GoodStudent(name,age){
        Person.call(this,name);
        this.age=age;
    }
    GoodStudent.prototype.sayAge=function(){
        alert(this.age);
    }
    //继承方法
    //用原型去继承实例的属性和方法
    GoodStudent.prototype=new Person();
    GoodStudent.prototype.constructor=GoodStudent;
    var g1=new GoodStudent("meng",18,"99");
    alert(g1.name);
    g1.sayName();

</script>
</body>
</html>